﻿<div class="wrapper border-bottom white-bg page-heading">
    <div class="col-lg-pull-12">
        <ol class="breadcrumb">
            <li class="active">商品</li>
        </ol>
    </div>
</div>
<div ng-controller="productController">
    <div class="row ui-box">
        <div class="col-md-4">
            <div class="input-group">
                <input type="text" class="form-control input-sm" ng-model="query.keyword" placeholder="商品名称">
                <span class="input-group-btn">
                    <button class="btn btn-primary btn-sm" type="button" ng-click="search()"><i class="fa fa-search"></i> 查询</button>
                </span>
            </div>
        </div>
    </div>
    <table class="table table-hover m-t-md">
        <thead>
            <tr>
                <th>名称 价格</th>
                <th width="80">类别</th>
                <th width="80">商户</th>
                <th width="80">库存</th>
                <th width="80">总销量</th>
                <th width="100">创建时间</th>
                <th width="175" style="text-align:right">操作</th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="item in list.rows">
                <td>
                    <div class="media">
                        <div class="media-left">
                            <a href="{{item.image_path[0]}}" target="_blank" class="thumbnail" style="width:60px;height:60px;">
                                <img ng-src="{{item.image_path[0]}}" ng-show="item.image_path" width="60" height="60">
                            </a>
                        </div>
                        <div class="media-body">
                            <p class="media-heading">{{item.name}}</p>
                            <span>{{item.price | currency:'￥'}}</span>
                        </div>
                    </div>
                </td>
                <td>{{item.category_id}}</td>
                <td>{{item.stock}}</td>
                <td>{{item.merchant.mobile}}</td>
                <td>{{item.sale_count}}</td>
                <td>{{item.create_time}}</td>
                <td align="right">
                    <a class="btn btn-primary btn-xs" ng-click="open_category(item)"><i class="fa fa-cog"></i> 编辑分类</a>
                    <a class="btn btn-primary btn-xs" ui-sref="app.product.audit_detail({action:'audit',id:item.id})" ng-if="item.audit_status == 1"><i class="fa fa-cog"></i> 审核</a>
                    <a class="btn btn-primary btn-xs" ng-click="disable(item.id)" ng-if="item.sale_status == 2"><i class="fa fa-cog"></i> 上架</a>
                    <a class="btn btn-primary btn-xs" ng-click="disable(item.id)" ng-if="item.sale_status == 1"><i class="fa fa-cog"></i> 下架</a>
                    <a class="btn btn-primary btn-xs" ui-sref="app.product.detail({action:'edit',id:item.id})"><i class="fa fa-cog"></i> 查看详情</a>
                    <!--<a class="btn btn-primary btn-xs" ng-click="remove(item)"><i class="fa fa-trash"></i> 删除</a>-->
                    <!--<a class="btn btn-primary btn-xs"clip-copy="site.share_url+'/'+item.shop_domain+'/goods/detail/'+item.id" clip-click="fallback()">复制</a>-->
                </td>
            </tr>
        </tbody>
    </table>
    <div class="row">
        <div class="col-md-12">
            <uib-pagination total-items="list.total_result" items-per-page="list.size" ng-model="list.page" num-pages="list.total_pages"
                            ng-change="search_page(list.page)" class="pagination-sm" boundary-links="true" boundary-link-numbers="true" max-size="20"
                            previous-text="&lsaquo;" next-text="&rsaquo;" first-text="&laquo;" last-text="&raquo;"></uib-pagination>
            <span class="pull-right" style="margin: 30px 0px 20px 0px">共{{list.total_result}} 当前：{{list.page}}/{{list.total_pages}}</span>
        </div>
    </div>
</div>

<script type="text/ng-template" id="category.html">
    <style type="text/css">
        .error {
            border-color: #f00;
        }
    </style>
    <div class="modal-header">
        <h3 class="modal-title">编辑商品分类</h3>
    </div>
    <form name="_form" class="form-horizontal w5c-form" w5c-form-validate="model.validateOptions" role="form" novalidate>
        <div class="modal-body">
            <div class="form-group">
                <p class="col-sm-2">当前分类</p>
                <div class="col-sm-3">
                    <p>{{model.category_f}}</p>
                </div>
            </div>
            <label ng-class="{error: error.f_c}">
                一级分类：
                <select ng-model="selected" ng-options="s.name for s in model.token_categorys" ng-change="c()">

                    <option value="">--请选择--</option>

                </select>

            </label>
            <label ng-show="selected.children.length" ng-class="{error: error.s_c}">
                二级分类：
                <select ng-model="selected2" ng-options="sh.name for sh in selected.children">

                    <option value="">--请选择--</option>

                </select>

            </label>
        </div>
        <div class="modal-footer">
            <button class="btn btn-primary" type="submit" w5c-form-submit="editCategory()" btn-loading="psdisabled.save" loading-text="保存中..." ng-disabled="psdisabled.save">
                确定
            </button>
            <button class="btn btn-primary" type="button" ng-click="cancel()">取消</button>
        </div>
    </form>
</script>